﻿<%dim respagecode%><% 'UTF-8%>

<% ''投诉单管理%>
<% ''加载通用函数和数据库连接%>
<!--#include file="../Include/Start.asp"-->
<%
	dim act ,ksrq,jsrq  ,strSql,rsObj
	set rsObj=Server.CreateObject("ADODB.Recordset")
	
	''act=ReplaceBadChar(Trim(request("act")))
	xxly=ReplaceBadChar(Trim(request("xxly")))
	ksrq=ReplaceBadChar(Trim(request("ksrq")))
	jsrq=ReplaceBadChar(Trim(request("jsrq")))
 	strSql=""
	strSql=strSql & " SELECT COUNT(tt.id) AS 数量, tt.消息来源_txt, tt.消息来源  ,tt.时间"
	strSql=strSql & " FROM (select mm.id ,mm.消息来源_txt ,mm.消息来源   "
	strSql=strSql & " , CAST(YEAR(mm.受理时间) AS varchar(4)) + '-' + RIGHT ('0'+CAST(MONTH(mm.受理时间) AS varchar(4)),2) AS 时间  "
	strSql=strSql & " from T_登记单 mm where 1=2  "
	if (""<>ksrq or ""<>jsrq or ""<>xxly ) then 
		strSql=strSql & " or ( 1=1 "
		if (""<>xxly) then strSql=strSql & " and mm.消息来源 ='"&xxly&"' "
		if (""<>ksrq) then strSql=strSql & " and mm.受理时间 >= CONVERT(DATETIME, '"&ksrq&" 00:00:00', 102) "
		if (""<>jsrq) then strSql=strSql & " and mm.受理时间 <= CONVERT(DATETIME, '"&jsrq&" 23:59:59', 102) "
		strSql=strSql & " )"
	end if 
	strSql=strSql & " ) tt GROUP BY tt.消息来源_txt, tt.消息来源, tt.时间 "
	strSql=strSql & " ORDER BY tt.时间, tt.消息来源"
     
 	''Response.Write strSql&"-----" 
 
	rsObj.Open strSql, Conn, 1, 3	
	dim arry(1000,20)	,dx,dy,dxtotal,dytotal
	dx=0 ''当前列
	dxtotal=dx
	dy=0 ''当然行
	do while not rsObj.eof
	 ''Response.Write dx&"_"&dy&"_"&Trim(rsObj("消息来源_txt"))&"_"&Trim(rsObj("时间"))&"_"&Trim(rsObj("数量"))&""&"<br>"
		if (arry(dy,0)<>Trim(rsObj("时间"))) then
			dy=dy+1
			dx=0
			arry(dy,0)=Trim(rsObj("时间"))
			dytotal=dy			
		end if
		dx=0
		''Response.Write ".......<br>"
		do while (arry(0,dx)<>Trim(rsObj("消息来源_txt")) and dx<=dxtotal )
			 ''Response.Write dxtotal&"_"&dx&"_"&arry(0,dx)&"?="&Trim(rsObj("消息来源_txt"))&"_"&""&"<br>"
			dx=dx+1
		loop
		 
		arry(0,dx)=Trim(rsObj("消息来源_txt"))
		if dxtotal<dx then dxtotal=dx
		 
		 ''arry(dy,dx)=dy&"/"&dx &":"&Trim(rsObj("数量"))
		 arry(dy,dx)= ""&Trim(rsObj("数量"))
		  ''Response.Write ""
		rsObj.movenext
		''rsObj.MoveLast
	loop 
	dim jj ,kk
	''Response.Write "<table>"
	for kk=0 to dytotal
	''Response.Write "<tr>"
		for jj=0 to dxtotal
			''Response.Write "<td>"
			''Response.Write "|"&kk&","&jj&" " & arry(kk,jj)&" "
			''''Response.Write  " " & arry(kk,jj)&" "
			''Response.Write "</td>"
		next 
		''Response.Write "</tr>"
	next 
	''Response.Write "</table>"
	
	
	
	''''''''''''输出xml begin'''''''''''''''
Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8"

Response.BinaryWrite( chrb(239) )
Response.BinaryWrite( chrb(187) )
Response.BinaryWrite( chrb(191) )

''' Now write your XML data to output stream 
	
	
Response.Write  "<chart palette='2' caption='投诉量统计' shownames='1' showvalues='1' decimals='0' numberPrefix='' useRoundEdges='1' legendBorderAlpha='0' xaxisname='月份' yaxisname='投诉量' numbersuffix='件' formatNumberScale='0' decimalPrecision='0' rotateValues='1'>"
  	for jj=1 to dxtotal 
 		Response.Write  "<dataset seriesName='" & arry(0,jj)&"'   showValues='1'>"&""
 		for kk=1 to dytotal
 			Response.Write  "<set value='" & arry(kk,jj)&"' />"
 		next
 		Response.Write  "</dataset>"
	next 
	Response.Write  "<categories>"			
		for jj=1 to dytotal 
			Response.Write  "<category label='" & arry(jj,0)&"' />"&" "
		next 
	Response.Write  "</categories>"
Response.Write  "</chart>"
	''''''''''''输出xml end''''''''''''''' 	
	%>			
<!--
<chart palette='2' caption='投诉量统计11' shownames='1' showvalues='1' decimals='0' 
numberPrefix='' useRoundEdges='1' legendBorderAlpha='0' xaxisname="月份" yaxisname="投诉量" 
numbersuffix="件" formatNumberScale='0' decimalPrecision='0' rotateValues='1'>

	<dataset seriesName='电话' color='AFD8F8' showValues='1'>
 
		<set value='25601.34' />
		<set value='20148.82' />
		<set value='17372.76' />
		<set value='35407.15' />
		<set value='38105.68' />
 
	</dataset>
	<dataset seriesName='网络' color='F6BD0F' showValues='1'>
		<set value='57401.85' />
		<set value='41941.19' />
		<set value='45263.37' />
		<set value='117320.16' />
		<set value='114845.27' />
	</dataset>
	<dataset seriesName='信件' color='8BBA00' showValues='1'>
		<set value='45000.65' />
		<set value='44835.76' />
		<set value='18722.18' />
		<set value='77557.31' />
		<set value='92633.68' />
	</dataset>

	<categories>
		<category label='1月' />
		<category label='2月' />
		<category label='3月' />
		<category label='4月' />
		<category label='5月' />
		<category label='6月' />
		<category label='7月' />
		<category label='8月' />
		<category label='9月' />
		<category label='10月' />
		<category label='11月' />
		<category label='12月' />
	</categories>
</chart>
		
-->
<%
	''关闭链接
	rsObj.close		

	call CloseConn
%>